#include <iostream>
using namespace std;
class Date
{
private:
    int year;
    int month;
    int date;

public:
    Date() = default;
    Date(const int year) : year(year) {}
    Date(const int year, const int month) : year(year), month(month) {}
    Date(const int year, const int month, const int date) : year(year), month(month), date(date) {}
    Date &add(int years)
    {
        year = year + years;
        return *this;
    }
    friend int find_day(const Date *date);
    friend int find_month(const Date *date);
    friend int find_year(const Date *date);
    inline const Date *max(const Date *date2)
    {
        if ((year > date2->year) || (year == date2->year && month > date2->month) || (year == date2->year && month == date2->month && date > date2->date))
            return this;
        else if (year == date2->year && month == date2->month && date == date2->date)
            return this;
        else
            return date2;
    }
    ~Date()
    {
        cout << year << " " << month << " " << date << " "
             << "it has been deleted." << endl;
    }
};
int find_day(const Date *date)
{
    return date->date;
}
int find_month(const Date *date)
{
    return date->month;
}
int find_year(const Date *date)
{
    return date->year;
}

int main(void)
{
    Date *date1 = new Date(2002, 8, 28);
    Date *date2 = new Date(1949, 10, 1);
    Date date3(1999,2,3);
    cout << find_day(date1) << endl;
    cout << find_month(date1) << endl;
    cout << find_year(date1) << endl;
    date1->add(18);
    cout << find_year(date1) << endl;
    cout << find_year(date2->max(date1)) << endl;
    delete date1;
    delete date2;
    return 0;
}